<!-- Start of Video page -->
<div data-role="page" id="video">

    <div data-role="header">
        <h1>วีดีโอคลิป</h1>
        <a rel="external" id="link_web" href="?q=home" data-icon="back" data-iconpos="right" data-transition="flip">กลับ</a> 
    </div><!-- /header -->

    <div data-role="content">	
        <ul data-role="listview">
            <li data-role="list-divider" id="listDivider_step">
                <a rel="external" href="?q=home">หน้าแรก</a>&nbsp;&nbsp;>>&nbsp;&nbsp;<a rel="external" href="?q=video">คลิป</a>
            </li>      
            <?php
            // set feed URL
            $feedURL = 'http://gdata.youtube.com/feeds/api/users/mocyctv/uploads';
            //https://gdata.youtube.com/feeds/api/users/mocyctv/uploads
            // read feed into SimpleXML object
            $sxml = simplexml_load_file($feedURL);

            // iterate over entries in feed
            foreach($sxml->entry as $entry)
            {
                // get nodes in media: namespace for media information
                $media = $entry->children('http://search.yahoo.com/mrss/');

                // get video player URL
                $attrs = $media->group->player->attributes();
                $watch = $attrs['url'];

                // get video thumbnail
                $attrs = $media->group->thumbnail[0]->attributes();
                $thumbnail = $attrs['url'];

                // get <yt:duration> node for video length
                $yt = $media->children('http://gdata.youtube.com/schemas/2007');
                $attrs = $yt->duration->attributes();
                $length = $attrs['seconds'];

                // get <yt:stats> node for viewer statistics
                $yt = $entry->children('http://gdata.youtube.com/schemas/2007');
                $attrs = $yt->statistics->attributes();
                $viewCount = $attrs['viewCount'];
                $vCount = ($viewCount < 3)? 0 : $viewCount;
                // get <gd:rating> node for video ratings
                $gd = $entry->children('http://schemas.google.com/g/2005');
                if($gd->rating)
                {
                    $attrs = $gd->rating->attributes();
                    $rating = $attrs['average'];
                }
                else
                {
                    $rating = 0;
                }
                ?>  
                <li>
                    <a href="<?php echo $watch; ?>" data-transition="slide">
                        <img class="img_video" src="<?php echo $thumbnail; ?>"/>
                        <h3><?php echo $media->group->title; ?></h3>
                        <p><?php echo $media->group->description; ?></p>
                        <p>ผู้ชม : <?php echo $vCount; ?> </p>
                    </a>
                </li>
                <?php
            }
            ?>
        </ul>   
    </div><!-- /content -->

    <div data-role="footer" >
        <h4>Version 1.0 Beta</h4>
        <a id="link_web" href="http://www.mocyc.com" data-icon="refresh" data-iconpos="right" class="ui-btn-right">แบบปกติ</a>

    </div><!-- /footer -->
</div><!-- /page -->    